<template>
  <van-nav-bar
    title="消费记录"
    left-text="返回"
    left-arrow
    fixed
    @click-left="onClickLeft"
  />
  <div class="item">
    <van-card v-for="item in recordList" :key="item.id" :title="item.content" >
        <template #desc>
            创建时间：{{item.createtime_text}}
        </template>
        <template #price>
            消费金额：{{item.total}}元
        </template>
    </van-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      LoginUser: this.$cookies.get("LoginAuth"),
      recordList: [],
    };
  },
  created() {
    this.getRecord();
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
    async getRecord() {
      let data = {
        busid: this.LoginUser.id,
      };

      let result = await this.$api.record(data);
      if (result.code == 1) {
        this.recordList = result.data;
      }
    },
  },
};
</script>

<style>
.item {
  padding-top: 45px;
}
</style>